package mirfordevoservice.system.req.impl;

import mirfordevoservice.system.GameCenter.GameDataManager;
import mirfordevoservice.system.req.ReqManager;
import mirfordevoservice.system.req.inter_face.ReqMessage;
import publicPackage.human.HumanData;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 * Created by Heart!
 *
 * @Author ZhangChaoJian
 * @Date ${Date}-20:22
 * Wants More Then Try Hard More!
 */

/**
 * 请求进入游戏的角色
 */
public class ReqEnterGame implements ReqMessage {

    @Override
    public void receive(ObjectInputStream in, Socket socket) {

    }

    @Override
    public void sendMsg(ObjectOutputStream out) {

    }

    @Override
    public void receiveAndSend(ObjectInputStream in, ObjectOutputStream out, Socket socket) {
        HumanData humanData;
        Object[] msgArray = ReqManager.getInstance().readMsg(2, in);
        humanData = GameDataManager.getInstance().enterGameHuman((Integer) msgArray[0], (Long) msgArray[1]);
        try {
            out.writeObject(humanData);
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
